from sqlalchemy import Column, Integer, String, Text, Numeric, DateTime, ForeignKey
from sqlalchemy.sql import func
from ..core.database import Base

class Product(Base):
    __tablename__ = "products"
    
    id = Column(Integer, primary_key=True, index=True)
    store_id = Column(Integer, ForeignKey("stores.id"), nullable=False)
    name = Column(String(100), nullable=False)
    description = Column(Text)
    images = Column(Text)  # 逗号分隔的图片URL
    original_price = Column(Numeric(10, 2))
    group_buy_price = Column(Numeric(10, 2))
    status = Column(Integer, default=1)  # 1:上架 0:下架
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) 